import { createStore } from 'redux'

const defData = {
    users: [
        { username: 'ligoudan', password: '123456' }
    ]
}

// 1. 正常地使用 redux 创建 store 和 reducer
const reducer = (state = defData, action) => {

    if (action.type === 'reg') {
        let newState = JSON.parse(JSON.stringify(state))
        newState.users.push(action.value)
        console.log(newState);
        return newState;
    }

    return state
}
const store = createStore(reducer)

export default store